package cn.edu.njpi.trip;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @author 朱宗辉
 * @version V1.0
 * @Package cn.edu.njpi.trip
 * @date 2021/12/12 上午2:05
 */
public class TripPartition extends Partitioner<Text, Text> {
    @Override
    public int getPartition(Text text, Text peopleBean, int numPartitions) {
        int partition = 2;
        if (peopleBean.toString().equals("red")) {
            partition = 0;
        } else if (peopleBean.toString().equals("yellow")) {
            partition = 1;
        } else {
            partition = 2;
        }
        return partition;
    }
}
